﻿<!DOCTYPE HTML>
<html>
<head>
<include file="public/header" />
<style>
	tbody tr:hover{
		background:#f1f1f1;
	}
</style>
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span> 管理员列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c"> 
		<form id="form-admin-add">
			日期范围：
			<input type="text" onfocus="WdatePicker()" name="datemin" value="{$datemin}" id="datemin" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" onfocus="WdatePicker()" name="datemax" value="{$datemax}" id="datemax" class="input-text Wdate" style="width:120px;">
			<input type="text" class="input-text" style="width:250px" placeholder="输入管理员名称" id="" name="username" value="{$username}">
			<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 开始检索</button>
		</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="javascript:;" onclick="admin_del_all()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
			<a href="javascript:;" onclick="edit_role_all('批量修改管理员角色','{:url("User/userroleall")}','800','250')" class="btn btn-warning radius"><i class="Hui-iconfont">&#xe6df;</i> 批量修改角色组</a> 
			<a href="javascript:;" onclick="admin_add('添加管理员','{:url("User/adduser")}','800','450')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a>
		</span> 
		<span class="r">共有数据：<strong>{:count($userlist)}</strong> 条</span> </div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="10">员工列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="40">ID</th>
				<th width="150">用户名</th>
				<th width="150">手机</th>
				<th width="150">邮箱</th>
				<th>角色</th>
				<th width="130">加入时间</th>
				<th width="100">是否已启用</th>
				<th width="200">操作</th>
			</tr>
		</thead>
		<tbody>
			<volist name='userlist' id='v'>
			<tr class="text-c">
				<td><input type="checkbox" value="{$v.id}" name=""></td>
				<td>{$v.id}</td>
				<td>{$v.username}</td>
				<td>{$v.tel}</td>
				<td>{$v.email}</td>
				<td>{$v.role}</td>
				<td>{$v.addtime|date='Y-m-d H:i:s',###}</td>
				<td class="td-status">
					<span class="label <if condition='$v["status"] eq 1'>label-success</if> radius">
					<if condition='$v["status"] eq 1'>已启用<else/>已停用</if>
					</span>
				</td>
				<td class="td-manage">
					<a title="修改密码" href="javascript:;" onclick="admin_edit('管理员修改密码','{:url("User/editpwd")}','{$v.id}','800','250')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>修改密码</a> 
					<a title="编辑" href="javascript:;" onclick="admin_edit('管理员编辑','{:url("User/adduser")}','{$v.id}','800','450')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a> 
					<a title="删除" href="javascript:;" onclick="admin_del(this,'{$v.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
				</td>
			</tr>
			</volist>
		</tbody>
	</table>
</div>
<include file="public/footer" />

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
/*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
/*管理员-增加*/
function admin_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*管理员-删除*/
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '{:url("User/deluser")}',
			dataType: 'json',
			data:{"id":id},
			success: function(data){
				if(data.error=="success"){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:6,time:2000});
				}else{
					layer.msg(data.error,{icon:5,time:2000});
				}
			},
			error:function(data) {
				layer.msg('操作失败!'+data.responseText,{icon:5,time:2000});
			},
		});		
	});
}
function admin_del_all(){
	layer.confirm('确认要删除选中的管理员吗？',function(index){
		//遍历所有复选框
		var dataarr=[];
		$("tbody input[type='checkbox']").each(function(){
			if($(this).prop("checked")){
				dataarr.push({"id":$(this).val()})
			}
		})
		if(dataarr.length<=0){
			layer.msg("请至少选择一条记录在操作",{icon:5,time:2000});
			return;
		}

		$.ajax({
			type: 'POST',
			url: '{:url("User/deluserAll")}',
			dataType: 'json',
			data:{"id":dataarr},
			success: function(data){
				if(data.error=="success"){
					layer.msg('已删除!',{icon:6,time:1000});
					setTimeout(function(){
						location.replace(location.href);
					},1500);
				}else{
					layer.msg(data.error,{icon:5,time:2000});
				}
			},
			error:function(data) {
				layer.msg('操作失败!'+data.responseText,{icon:5,time:2000});
			},
		});		
	});
}

/*批量修改角色*/
function edit_role_all(title,url,w,h){
	layer.confirm('确认要批量修改选中管理员的角色吗？',function(index){
		//遍历所有复选框
		var datastr="";
		$("tbody input[type='checkbox']").each(function(){
			if($(this).prop("checked")){
				datastr+=$(this).val()+",";
			}
		})
		if(datastr.length<=0){
			layer.msg("请至少选择一条记录在操作",{icon:5,time:2000});
			return;
		}
		datastr=datastr.substring(0,datastr.length-1);
		layer_show(title,url+"?id="+datastr,w,h);
	});
}

/*管理员-编辑*/
function admin_edit(title,url,id,w,h){
	layer_show(title,url+"?id="+id,w,h);
}
</script>
</body>
</html>